"""
统计同一字符串出现的次数
随机生成一个字符串，使用字符串的count方法进行统计
"""
import random
import string

result = {}
# 随机生成一个字符串
# 获取相关长度随机数
n1 = random.randint(1, len(string.digits))
n2 = random.randint(1, len(string.ascii_letters))
n3 = random.randint(1, len(string.punctuation))
print(n1, n2, n3)

# 获取随机长度的指定字符
con1 = random.sample(string.digits, n1)
con2 = random.sample(string.ascii_letters, n2)
con3 = random.sample(string.punctuation, n3)
print(con1, con2, con3)

# 进行相关内容的合并
r1 = ''.join(con1)
r2 = ''.join(con2)
r3 = ''.join(con3)
strCon = r1 + r2 + r3

for i in strCon:
    n = strCon.count(i)
    result[i] = n

print(result)